#include "CTween.h"

Int32 CALLBACKTYPE GetSinusoidalValue(
    /* [in] */ Int32 fromValue,
    /* [in] */ Int32 toValue,
    /* [in] */ Millisecond32 elaspedTime,
    /* [in] */ Millisecond32 durationTime,
    /* [in] */ EaseType easeType)
{
    double dx = (double)(toValue - fromValue);
    double delta = 0;

    switch (easeType) {
        case EaseType_In:
        delta = dx - dx * cos(elaspedTime * HALF_PI / durationTime);
        break;

        case EaseType_Out:
        delta = dx * sin(elaspedTime * HALF_PI / durationTime);
        break;

        case EaseType_InOut:
        delta = dx * (0.5 - 0.5 * cos(GFX_PI * elaspedTime / durationTime));
        break;

        default:
            assert(0);
    }

    return (Int32)(fromValue + delta);
}
